package com.luanye.enjoy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luanye.enjoy.entity.Recipe;
import com.luanye.enjoy.mapper.RecipeMapper;
import com.luanye.enjoy.service.RecipeService;
import com.luanye.enjoy.vo.RespBean;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("recipeService")
public class RecipeServiceImpl extends ServiceImpl<RecipeMapper, Recipe> implements RecipeService {

    @Override
    public RespBean findByType(Integer id) {
        LambdaQueryWrapper<Recipe> query = new LambdaQueryWrapper<>();
        query.eq(Recipe::getTypeId, id);

        List<Recipe> recipes = baseMapper.selectList(query);
        return RespBean.success(recipes);
    }

    @Override
    public RespBean findByName(String name) {
        List<Recipe> recipes = baseMapper.findByName(name);
        return RespBean.success(recipes);
    }
}
